<?php

// $Id$

require_once(TANGRA_MAIN_DIR.'form/guardable_form.class.php');
require_once(TANGRA_MAIN_DIR.'form/fields/text/form_field_text.class.php');
require_once(TANGRA_MAIN_DIR.'form/fields/integer/form_field_integer.class.php');
require_once(TANGRA_MAIN_DIR.'form/fields/checkbox/form_field_checkbox.class.php');
require_once(TANGRA_MAIN_DIR.'/form/static_html_form_generator.class.php');


class VPage_Template_Form extends Guardable_Form {
	function __construct() {
		parent::__construct('vpage_template', 'admin/modules/tangra_cms/vpage/vpage_template_edit.php');

		$f_name = new Form_Field_Text('name', true, 255);
		$this->add_field($f_name);

		$f_wp_path = new Form_Field_Text('wp_path', true, 255);
		$f_wp_path->add_potential_error('file_not_exist');
		$this->add_field($f_wp_path);

		$f_wp_class_name = new Form_Field_Text('wp_class_name', true, 255);
		$this->add_field($f_wp_class_name);

		$f_page_name = new Form_Field_Text('page_name', true, 255);
		$this->add_field($f_page_name);

		$f_edit_path = new Form_Field_Text('edit_path', false, 255);
		$f_edit_path->add_potential_error('file_not_exist_ht');
		$this->add_field($f_edit_path);

		$f_man_path = new Form_Field_Text('man_path', false, 255);
		$f_man_path->add_potential_error('file_not_exist_ht');
		$this->add_field($f_man_path);

		$f_del_path = new Form_Field_Text('del_path', false, 255);
		$f_del_path->add_potential_error('file_not_exist_ht');
		$this->add_field($f_del_path);

		$f_cache = new Form_Field_Checkbox('cache');
		$this->add_field($f_cache);

		$f_cache_expiry = new Form_Field_Integer('cache_expiry', true, 6 , 0);
		$this->add_field($f_cache_expiry);

		$f_hard_cache = new Form_Field_Checkbox('hard_cache');
		$this->add_field($f_hard_cache);

		$f_update = new Form_Field_Checkbox('update');
		$this->add_field($f_update);
	}


	public function generate_html() {
		$html_gen = new Static_HTML_Form_Generator($this, 'modules/form_html_tpl_static_ajax_metallic_en', 'en');
		$html_gen->create_default_tpl_maps();
		$html_gen->change_field_p_error_map_entry('wp_path', 'file_not_exist', 'modules/tangra_cms/forms/en/vpage_template/field_error_file_not_exist_en.tpl');
		$html_gen->change_field_p_error_map_entry('edit_path', 'file_not_exist_ht', 'modules/tangra_cms/forms/en/vpage_template/field_error_file_not_exist_ht_en.tpl');
		$html_gen->change_field_p_error_map_entry('man_path', 'file_not_exist_ht', 'modules/tangra_cms/forms/en/vpage_template/field_error_file_not_exist_ht_en.tpl');
		$html_gen->change_field_p_error_map_entry('del_path', 'file_not_exist_ht', 'modules/tangra_cms/forms/en/vpage_template/field_error_file_not_exist_ht_en.tpl');

		printbr('<pre>');
		printbr(htmlentities($html_gen->get_static_html()));
		printbr('</pre>');
	}
}
